<template>
  <div class="container-pt">
    <van-nav-bar left-arrow @click-left="$router.back()" fixed title="我的文章" />
    <article-list :disable-swiper="false" >
      <template #rights="{id}">
        <van-button square type="warning" @click="edit(id)" text="修改" />
        <van-button square type="danger" text="删除" @click="del(id)" />
      </template>
    </article-list>
    <van-popup v-model="active" style="height:100%" position="bottom">
      <van-nav-bar title="修改文章">
        <template #right>
          <van-icon name="close" @click="active=false" size="18" />
        </template>
      </van-nav-bar>
      <article-form :editid="editid" :active.sync="active"></article-form>
    </van-popup>
  </div>
</template>

<script>
import articleList from '@/components/article-list.vue'
import articleForm from '@/components/article-form.vue'
import { getmyarticle } from '@/api/userinfo'
import { delarticle } from '@/api/delart'
// import {getdetail} from '@/api/index'
export default {
  components: { articleList, articleForm },
  data () {
    return {
      active: false,
      params: {
        page: 1,
        limit: 20
      },
      myarticle: [],
      // editdetail:{}
      editid: ''
    }
  },

  methods: {
    async getart () {
      const res = await getmyarticle(this.params)
      console.log(res);
      this.myarticle = res.data.data
    },

    async del (id) {
      console.log(id);
      const res = await delarticle(id)
      console.log(res);
      this.$toast.success('删除成功')
      this.$router.go(0)
    },
    async edit (id) {
      this.active = true
      // this.$router.push({path:'/add',query:{id:id}})
      console.log(id);
      this.editid = id
      // const res = await getdetail(id)
      // console.log(res.data.info);
      // this.editdetail=res.data.info
    }
  }
};
</script>

<style>
</style>